 <!-- 地址管理 -->
<template>
  <div class="box_container">
    <!-- 输入框 -->
    <div class="box_input">
      <el-input v-model="pageinfo.userId" placeholder="请输入用户ID" @input="inputchang"></el-input>
      <el-button icon="el-icon-search" type="primary" @click="onSeek">查找</el-button>
    </div>
    <div class="box_table">
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column prop="id" label="地址Id">
        </el-table-column>
        <el-table-column prop="userId" label="用户Id">
        </el-table-column>
        <el-table-column prop="consignee" label="签收人">
        </el-table-column>
        <el-table-column prop="province" label="省份">
        </el-table-column>
        <el-table-column prop="city" label="城市">
        </el-table-column>
        <el-table-column prop="county" label="区/县">
        </el-table-column>
        <el-table-column prop="address" label="详情地址">
        </el-table-column>
      </el-table>
    </div>
    <!-- 分页 --回到顶部 -->
    <div class="box_paging">
      <pagination :pageinfo="pageinfo" @change="changePage"></pagination>
    </div>
  </div>
</template>
<script>
import Pagination from "../../components/pagination/MyPagination.vue"
import Apiadmin from "../../api/admin"
export default {
  components: { Pagination },
  data() {
    return {
      pageinfo: {
        limit: 10, //每页显示的数量
        page: 1,  //当前显示的页码
        total: 0, //数据总条数
        userId: '', //用户id
      },

      tableData: [], //表格数据
    }
  },
  created() {
    this.operateList()
  },
  methods: {
    // 子传过来的方法和页长跟当前页
    changePage(e) {
      console.log(e)
      this.pageinfo = JSON.parse(JSON.stringify(e))
      this.$nextTick(() => {
        this.operateList()
      })
    },
    //搜索
    inputchang(e) {
      console.log(e)
      this.pageinfo.userId = e
    },
    // 查找
    onSeek() {
      this.pageinfo.page = 1  //重置page为1
      this.operateList()
    },
    // 请求地址管理数据
    operateList() {
      Apiadmin.addList(this.pageinfo).then(res => {
        console.log(res)
        if (res.errno == 200) {
          this.tableData = res.data.items  //表格数据
          this.pageinfo.total = res.data.count  //分页总数据
        }
      })
    },

  }
}
</script>
<style scoped  lang="less">
.box_input {
  .el-input {
    width: 20%;
  }
}
</style>